#include "widget.h"
#include "ui_widget.h"

#include <fstream>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //打开文件
    std::ifstream file("D:/aQT/qt-study/ComboBox_2/config.txt");
    if(!file.is_open())
    {
        qDebug() << "打开文件失败";
        return;
    }
    //按照行来读取文本
    std::string line;
    while(std::getline(file, line))
    {
        ui->comboBox->addItem(QString::fromStdString(line));
    }
    //关闭文件
    file.close();
}

Widget::~Widget()
{
    delete ui;
}

